extends Area2D
class_name Bullet

@export var speed: int =20
@export var damage:int = 20

var direction := Vector2.ZERO
var damage_mult:float = 1.0
var cur_damage  = damage

#子弹位移
func _physics_process(delta: float) -> void:
	if direction != Vector2.ZERO:
		var velocity = direction * speed

		global_position += velocity

#飞行方向和旋转角度
func set_direction(direction: Vector2):
	self.direction = direction
	rotation += direction.angle()

#计时子弹销毁
func _on_kill_timer_timeout():
	queue_free()

#命中反馈
func _on_body_entered(body):
	if body.has_method("handle_hit"):
		body.handle_hit(cur_damage)
	queue_free()
